<template>
    <div class="radiodetails">

        <div class="one-radio-header">
            <!-- <img :src="details?.json_content.cover" class="one-image-exclude"> -->
            <van-image :src="details?.json_content.cover" fit="contain" class="one-image-exclude"></van-image>
            <div class="one-bg-gif" v-if="playing">
                <i class="one-icon" @click="toggle"></i>
            </div>
            <div class="one-bg-png" v-else>
                <i class="one-icon" @click="toggle"></i>
            </div>
            <div class="navigation">
                <img src="./image/返回箭头.png" @click="$router.back()">
            </div>
        </div>
        <!-- 标题 -->
        <div class="one-title-box">{{ details?.title }}</div>
        <div class="one-simple-author-box">
            <span class="name">{{ details?.json_content.simple_author[0] }}</span>
            <span class="volume">{{ details?.json_content.simple_author[1] }}</span>
        </div>
        <div class="text-content" v-html="details?.json_content.content"></div>

        <!-- 文本内容 -->
        <div class="one-editor-box">
            {{ details?.json_content.editor }}
        </div>
        <div class="one-radio-intro-box">
            <table style="width:100%">
                <tbody>
                    <tr>
                        <td width="60rem">

                            <van-image src="http://image.wufazhuce.com/radio_banner_180_180.jpg?1"
                                class="one-image-exclude"></van-image>
                        </td>
                        <td>
                            <div class="one-radio-intro-title">ONE收音机</div>
                            <div class="one-radio-intro-brief">“讲述生活，与你常在。”
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- 主播 -->
        <div class="page-sparate-title">
            主播
        </div>
        <hr />
        <div class="page-author" v-for="authors in details?.json_content.author?.authors" :key="authors.id">
            <div class="author-left" @click="AuthorDetails(authors.id)">
                <!-- <img :src="authors.avatar" class="avatar"> -->
                <van-image :src="authors.avatar" round class="avatar"></van-image>
                <div class="introduce">
                    <div class="name">{{ authors.name }}</div>
                    <div class="brief">{{ authors.brief }}</div>
                </div>
            </div>
            <div class="author-right">
                <button>关注</button>
            </div>
        </div>
        <!-- 评论列表 -->
        <div class="page-sparate-title">
            评论列表
        </div>
        <hr />
        <div class="content" v-for="content in comments" :key="content.id">
            <!-- 用户 -->
            <div class="content-top">
                <div class="content-user">
                    <div class="user-img">
                        <!-- <img :src="content.user.web_url"  class="avatar"> -->
                        <van-image :src="content.user.web_url" :round="true" class="avatar"></van-image>
                    </div>
                    <span class="user-name">{{ content.user.user_name }}</span>
                </div>
                <div class="content-time">{{ content.created_at }}</div>
            </div>
            <!-- 品论内容 -->
            <div class="content-center">{{ content.content }}</div>

            <div class="content-bottom">
                <div class="comments">
                    <img src="./image/评论-24.png">
                </div>
                <div class="thumbsup">
                    <img src="./image/点赞.png">
                </div>
                <div class="praisenum">{{ content.praisenum }}</div>
            </div>
        </div>
    </div>

</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import axios from 'axios';
import { getHtmlcontent,getCommentPraiseandtime } from '@/api/radio';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
let router = useRouter();
const details = ref();
const comments = ref();

// 控制音乐播放
const playing = ref(true);
onMounted(() => {
    // axios.get("https://apis.netstart.cn/one/radio/htmlcontent/4820").then((res) => {
    //     details.value = res.data.data;

    // });
    // axios.get("https://apis.netstart.cn/one/comment/praiseandtime/radio/4820/0").then((res) => {
    //     comments.value = res.data.data.data;
    //     console.log(res.data.data.data);
    // });

    getHtmlcontentData();
    getCommentPraiseandtimeData();
});
let route = useRoute(); 

// 获取电台详细内容
let getHtmlcontentData = async() =>{
    details.value = (await getHtmlcontent(route.query.id)).data
}
// 评论区
let getCommentPraiseandtimeData = async() =>{
    comments.value = (await getCommentPraiseandtime(route.query.id)).data.data
}
const toggle = () => {
    playing.value = !playing.value
}
// 跳转到用户详细
let AuthorDetails = (id: String) => {
    router.push({ path: "/AuthorDetails", query: { id: String(id) } });
    
};
</script>

<style scoped>
.radiodetails {
    position: relative;


    .one-radio-header {
        position: relative;
        .one-image-exclude {
            width: 100%;
            height: 200rem;
            margin-bottom: 0;
            margin-top: 0;
            vertical-align: middle;
        }

        /* 音乐暂停和播放 */
        .one-bg-gif,
        .one-bg-png {
            position: absolute;
            z-index: 500;
            width: 280rem;
            height: 20rem;
            left: 50%;
            transform: translateX(-50%);
            bottom: 30rem;
            margin: 0 0 0 0;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            text-align: center;
        }

        .one-bg-gif {
            margin-bottom: 0;
            margin-top: 0;
            display: inline-block;
            background-image: url("./image/ratebar.gif");
            /* background-color: red; */


            .one-icon {
                color: white;
                padding: 10.5rem 16rem;
                padding-bottom: 0;
                background: url("./image/暂停.png") no-repeat;
                background-size: 30rem;
            }
        }

        .one-bg-png {
            margin-bottom: 0;
            margin-top: 0;
            display: inline-block;
            background-image: url("./image/ratebar.png");

            .one-icon {
                color: white;
                padding: 10rem 15rem;
                background: url("./image/播放.png") no-repeat;
                background-size: 30rem;
            }
        }

        /* 顶部导航栏 */
        .navigation{
            position: absolute;
            top: 0;
            width: 100%;
            height: 40rem;
            img{
                width: 35rem;
                height: 30rem;
                margin-top: 7rem;
                margin-left: 7rem;
            }
        }
    }

    .one-title-box {
        font-size: 25rem;
        font-weight: 700;
        margin: 20rem 15rem;
    }

    .one-simple-author-box {
        margin-top: 20rem;
        display: table;
        width: 100%;

        span {
            display: table-cell;
            font-size: 12rem;
            vertical-align: middle;
        }

        .name {
            padding-left: 15rem;
        }

        .volume {
            text-align: right;
            padding-right: 15rem;
        }
    }

    .text-content,
    .one-editor-box {
        margin: 12rem 15rem 0 15rem;

    }

    .text-content {
        /* line-height: 1.7rem; */

    }

    .one-editor-box {
        margin-top: 15rem;
        color: #808080;

        font-size: 12rem;
    }

    .one-radio-intro-box {
        margin-top: 12rem;
        background-color: #FBFBFB;
        /* padding: .01rem 0; */
        padding: 12rem 15rem;

        .one-image-exclude {
            width: 50rem;
        }

    }

    .page-sparate-title {
        padding: 0 15rem;
        margin-top: 12rem;
    }

    hr {
        color: black;
        background-color: black;
        width: 100rem;
        height: 6rem;
        margin-left: 15rem;
        margin-top: 17rem;
    }

    .page-author {
        margin: 30rem 15rem;
        display: flex;
        justify-content: space-between;

        .author-left {
            display: flex;

            .avatar {
                width: 35rem;
                border-radius: 50%;
            }

            .introduce {
                margin-left: 15rem;

                .brief {
                    font-size: 10rem;
                    color: #808080;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    white-space: nowrap;
                }
            }
        }

        .author-right {
            button {
                border: 1.5rem solid #b3b3b3;
                background-color: white;
                padding: 5rem;
                color: #8e8e8e;
                border-radius: 10%;

            }
        }
    }

    /* 评论列表 */
    .content {
        margin: 0 15rem;
        border-bottom: 1px solid #ededed;

        .content-top {
            display: flex;
            justify-content: space-between;
            align-items: center;

            .content-user {
                display: flex;
                align-items: center;
                margin: 20rem 0;

                .user-img {
                    .avatar {
                        width: 18rem;
                        border-radius: 50%;
                    }
                }

                .user-name {
                    color: #979797;
                    font-size: 12rem;
                    margin-left: 8rem;
                    margin-bottom: 3rem;
                }

            }

            .content-time {
                color: #7f7f7f;
                font-size: 10rem;
            }
        }

        .content-center {
            margin: 0 0 15rem 15rem;
        }

        .content-bottom {
            display: flex;
            justify-content: end;
            color: #7f7f7f;

            .comments {
                margin-right: 10rem;
            }

            .thumbsup {
                margin-right: 3rem;

            }

            img {
                width: 15rem;
            }

            .praisenum {
                font-size: 14rem;
                width: 30rem;
            }
        }
    }
}
</style>
